package image;

import java.awt.Color;
import java.awt.Graphics;

import javax.swing.JComponent;
import javax.swing.JSlider;
import javax.swing.plaf.basic.BasicSliderUI;
/**An UI for sliders which is less broken than the default, in some L&Fs*/
public class ThumbSliderUI extends BasicSliderUI 
	{
	public ThumbSliderUI(JSlider slider)
		{
		super(slider);
		}
	@Override 
	protected void scrollDueToClickInTrack(int direction) 
		{
		if(slider.getMousePosition()!=null) 
			slider.setValue(valueForXPosition(slider.getMousePosition().x));
		}
	@Override
	public void paint(Graphics g, JComponent c)
		{
		g.translate(0, 2);
		super.paint(g, c);
		g.translate(0, -2);
		g.setColor(Color.BLACK);
		g.drawLine(thumbRect.x, slider.getHeight()-1, thumbRect.x+thumbRect.width-1, slider.getHeight()-1);
		}
	}